<?php 
    require_once 'all_fns.php';
    
    session_start();
    
    $olduser = $_SESSION[STR_valid_user];
    
    if(isset($olduser))
    {
        unset($_SESSION[STR_valid_user]);
        if(session_destroy())
        {
            $msg_response = new message(
                array('succeed'=>true, 'id'=>$olduser), 1, STR_array);           
        }
        else
        {
            $msg_response = new message(
                array('succeed'=>false, 'id'=>$olduser, 'msg'=>"Logged out failed."), 0, STR_array); 
        }
    }
    else
    {
        $msg_response = new message(
            array('succeed'=>false, 'id'=>$olduser, 'msg'=>"You were not logged in, and so have not been logged out."), 0, STR_array);
    }
    
    echo json_encode($msg_response);    
    
?>